//输入框自动聚焦
const directiveObj = {
  install(Vue) {
    Vue.directive('fofo', {
      inserted(el) {
        if (el.nodeName == 'TEXTAREA' || el.nodeName == 'INPUT') {
          el.focus()
        } else {
          var theInput = el.querySelector('input')
          var theTextarea = el.querySelector('textarea')

          if (theInput) theInput.focus();
          if (theTextarea) theTextarea.focus();
        }
      },
      update(el) {
        if (el.nodeName == 'TEXTAREA' || el.nodeName == 'INPUT') {
          el.focus()
        } else {
          var theInput = el.querySelector('input')
          var theTextarea = el.querySelector('textarea')

          if (theInput) theInput.focus();
          if (theTextarea) theTextarea.focus();
        }
      }
    })
  }
}


export default directiveObj
